package com.ramnight.unify.boot.redis;

import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;

import com.alibaba.fastjson.support.spring.FastJsonRedisSerializer;

public class UnifyRedisTemplate extends RedisTemplate<String, String> {
	private static final FastJsonRedisSerializer<String> SERIALIZER = new FastJsonRedisSerializer<String>(String.class);

	public UnifyRedisTemplate() {
		setKeySerializer(SERIALIZER);
		setValueSerializer(SERIALIZER);
		setHashKeySerializer(SERIALIZER);
		setHashValueSerializer(SERIALIZER);
	}

	public UnifyRedisTemplate(RedisConnectionFactory connectionFactory) {
		this();
		setConnectionFactory(connectionFactory);
		afterPropertiesSet();
	}
}
